Skip to content

Conversation

@jssmith
Copy link
Contributor

@jssmith jssmith commented Jan 19, 2026

Summary

Fixes handling of uppercase/quoted sequence names in the health check. Previously, sequence names like "UpperCaseOrders_id_seq" would be double-quoted when passed to sql.Identifier, causing query failures.

Supersedes #94 - thanks @gsoltis for identifying the issue and initial fix!

Changes

  • Strip quotes from parsed sequence names before passing to sql.Identifier
  • Improved docstring documenting supported formats and known limitations
  • Better test coverage:
    • Restored original test_orders (lowercase) test case
    • Added separate "UpperCaseOrders" table to specifically test quoted identifier handling
    • New unit test file with 8 test cases for _parse_sequence_name
    • Documented known limitation (sequence names containing dots) with xfail test

Known Limitation

Sequence names containing literal dots (e.g., "my.seq") are not supported and will be incorrectly parsed. This is an edge case documented in the tests.

Test Plan

  • Run pytest tests/unit/database_health/ to verify unit tests pass
  • Run integration tests with a database containing uppercase table names

🤖 Generated with Claude Code


Fixes #109

gsoltis and others added 2 commits July 15, 2025 11:32
- Restore original lowercase test_orders table
- Add separate UpperCaseOrders table to test quoted identifier handling
- Add unit tests for _parse_sequence_name covering various formats
- Document known limitation: sequence names with dots not supported

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c837881f48

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 149 to 151
# Remove nextval and cast parts
clean_value = default_value.replace("nextval('", "").replace("'::regclass)", "")
clean_value = clean_value.replace("('", "").replace("'::text)", "")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Strip text-cast wrappers when parsing nextval

For the nextval(('id_seq'::text)::regclass) format the docstring and new tests mention, the current replacement chain doesn’t actually remove the outer nextval( or the trailing ::regclass) because replace("nextval('") never matches when there’s an extra (. That leaves clean_value as something like nextval(id_seq::regclass), so _parse_sequence_name returns public, nextval(id_seq::regclass) and subsequent Identifier lookups will fail. This will also make the new test_text_cast_format fail unless the parsing logic is updated to handle the extra parentheses.

Useful? React with 👍 / 👎.

jssmith and others added 3 commits January 19, 2026 18:41
Use regex to extract sequence name from nextval() expressions.
The previous string replacement approach failed for the
nextval(('id_seq'::text)::regclass) format.

Thanks to Codex for catching this issue.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add type: ignore comment since _parse_sequence_name doesn't use sql_driver.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@jssmith
Copy link
Contributor Author

jssmith commented Jan 19, 2026

@codex review

@chatgpt-codex-connector
Copy link

Codex Review: Didn't find any major issues. Keep them coming!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@jssmith jssmith merged commit 4cd8d44 into main Jan 19, 2026
1 check passed
@jssmith jssmith deleted the fix-sequence-quoting branch January 19, 2026 19:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

analyze_db_health incorrectly parses double quotation marks for db objects with them

3 participants